//
//  PutForwardRecordStore.m
//  NewPro
//
//  Created by RYX on 2018/10/23.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "PutForwardRecordStore.h"
#import "IncomeModel.h"
#import "PutForwardRecordModel.h"

@implementation PutForwardRecordStore

#pragma mark - 获取验证码
- (void)getCodeWithPhone:(NSString *)phone Success:(void(^)(void))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/validate/mobile/confirm",IP];
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    if (phone.length > 0) {
    
        [dic setObject:phone forKey:@"phone"];
    }
    
    [HttpTool getUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            success();
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

#pragma mark - 提现操作
- (void)putForwardWithSecret:(NSString *)secret amount:(NSString *)amount type:(NSString *)type cardId:(NSString *)cardId Success:(void(^)(void))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/wallet/v2/withdraw/divided",IP];
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:secret forKey:@"secret"];
    [dic setObject:amount forKey:@"amount"];
    [dic setObject:type forKey:@"type"];
    [dic setObject:cardId forKey:@"cardId"];
    [dic setObject:@"1" forKey:@"version"];
    
    [HttpTool postUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            success();
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

#pragma mark - 提现记录
- (void)getForwardRecordWithCustomId:(NSString *)customId Success:(void(^)(NSArray *listArr))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/getMoney/record",IP];
    
    NSDictionary *dic = @{
                          @"customId":customId
                          };
    
    [HttpTool postUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            NSArray *listArr = [PutForwardRecordModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"items"]];
            success(listArr);
            
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}
@end
